home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / pcpilot.arc / SCR.ARC / KBD.C < prev    next >
Text File  |  1990-01-14  |  2KB  |  58 lines

  1. /* ------------------------------------------------------------------------ */
  2. /*                                  KBD.C                                     */
  3. /*                                                                          */
  4. /*               See pg. 79 of Systems Programming In Turbo C                  */
  5. /*                                                                          */
  6. /* ------------------------------------------------------------------------ */
  7.  
  8. #pragma inline            /* notify compiler of inline assembly language */
  9.  
  10. #include <dos.h>
  11. #include "kbd.h"
  12.  
  13. void KbdFlush()
  14. /*
  15.     This function flushes the keyboard buffer maintained by the BIOS
  16. */
  17. {
  18. a01:;
  19.     asm    mov    ah, 01;        /* BIOS service 1: determine if key is ready */
  20.     asm int 16h;        /* BIOS keyboard services */
  21.     asm jz a02;            /* ZF = 1 means no key ready */
  22.  
  23.     asm mov ah, 00;        /* BIOS service 0: read key */
  24.     asm int 16h;
  25.  
  26.     asm jmp a01;        /* return for another key */
  27. a02:;
  28. }
  29.  
  30.  
  31. int KbdGetShift()
  32. /*
  33.     This function returns the BIOS shift status word
  34. */
  35. {
  36.     return *((int far *)0x00400017);
  37. }
  38.  
  39.  
  40. void KbdSetShift(int ShiftStat)
  41. /*
  42.     This function sets the BIOS shift status word
  43. */
  44. {
  45.     *((int far *)0x00400017) = ShiftStat;
  46. }
  47.  
  48. int KbdGetC()
  49. /*
  50.     This function reads a key using the BIOS. The return value contains:
  51.         High-order byte:    Extended code
  52.         Low-order byte:        ASCII value
  53. */
  54. {
  55.     _AH = 0;                /* BIOS service 0: read keyboard */
  56.     geninterrupt (0x16);    /* BIOS keyboard services */
  57.     return (_AX);            /* Extended code/ASCII value returned in AH/AL */
  58. }